# # while 循环
# unconfirmed_users = ['alice', 'brian', 'candace']
# confirmed_users = []
# while unconfirmed_users:
#     current_user = unconfirmed_users.pop()
#     print(f"Verifying user: {current_user.title()}")
#     confirmed_users.append(current_user)
# print("\nThe following users have been confirmed:")

# for confirmed_user in confirmed_users:
#     print(confirmed_user.title())


# # while 删除

# pets = ['dog', 'cat', 'dog', 'goldfish', 'cat', 'rabbit', 'cat']
# print(pets)
# while 'cat' in pets:
#     pets.remove('cat')
# print(pets)

# #使⽤⽤户输⼊填充字典
# infos = {}
# while True:
#     name = input("Enter a name: ")
#     age = input("Enter your age:")
#     infos[name] = age

#     repeat = input("Would you like to let another person respond?(yes/no) ")
#     if repeat == 'no':
#         break

# for n,a in infos.items():
#     print(f'name:{n}, age:{a}')



# 练习 7.8：熟⾷店 创建⼀个名为 sandwich_orders 的列表，其中
# 包含各种三明治的名字，再创建⼀个名为 finished_sandwiches
# 的空列表。遍历列表 sandwich_orders，对于其中的每种三明治，
# 都打印⼀条消息，如“I made your tuna sandwich.”，并将其移到列表
# finished_sandwiches 中。当所有三明治都制作好后，打印⼀条消
# 息，将这些三明治列出来。
sandwich_orders = ['pastrami', 'beef', 'pastrami', 'chicken', 'tuna']
finished_sandwiches=[]
while sandwich_orders:
    order = sandwich_orders.pop()
    print(f"I made your {order} sandwich")
    finished_sandwiches.append(order)


# 练习 7.9：五⾹烟熏⽜⾁卖完了 使⽤为练习 7.8 创建的列表
# sandwich_orders，并确保 'pastrami' 在其中⾄少出现了三次。
# 在程序开头附近添加这样的代码：先打印⼀条消息，指出熟⾷店的五
# ⾹烟熏⽜⾁（pastrami）卖完了；再使⽤⼀个 while 循环将列表
# sandwich_orders 中的 'pastrami' 都删除。确认最终的列表
# finished_sandwiches 中未包含 'pastrami'。
sandwich_orders = ['pastrami', 'beef', 'pastrami', 'chicken', 'pastrami']

while 'pastrami' in sandwich_orders:
    sandwich_orders.remove('pastrami')
print(sandwich_orders)



# 练习 7.10：梦想中的度假胜地 

# 编写⼀个程序，调查⽤户梦想中的度
# 假胜地。使⽤类似于“If you could visit one place in the world, where
# would you go?”的提⽰，并编写⼀个打印调查结果的代码块。

responses = {}
poll_active = True
while poll_active:
    name = input("What's your name? ")
    place = input("If you could visit one place in the world, where would you go?")
    responses[name] = place
    repeat = input("Would you like to let another person respond?(yes/no) ")
    if repeat == 'no':
        poll_active = False
        
for n,a in responses.items():
    print(f'{n} would like to visit {a}')


